Skip to contentSkip to conversation

Change in openvpn[master]: test_dhcp: Start a dhcp helper functions UT

Openvpn-devel In review flichtenheld (Code Review) 2 participants 11 messages Oct 10, 2025 – Oct 13, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1760136547000.I08e50030b1b692d351509f541e5c0b03b5170615@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email

to review the following change.

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 154 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/1

CMakeLists.txt +6 -0
index 37bfc03..811a324 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_packet_id"
@@ -918,6 +919,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 8e94665..79987ad 100644
@@ -4,7 +4,7 @@
 
 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING) Unit-Tests'
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -71,6 +71,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +133 -0

133 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

Patch Set 1: Code-Review-2

(1 comment)

Patchset:

PS1:

```
test_dhcp.c: In function ‘test_write_dhcp_search_str’:
test_dhcp.c:71:83: error: \x used with no following hex digits
   71 |     const char output_1[27] = "\x77\x1a\x07openvpn\x03net\x00\x07openvpn\x{03}com";
      |                                                                                   ^
test_dhcp.c:71:31: error: initializer-string for array of ‘char’ is too long [-Werror]
   71 |     const char output_1[27] = "\x77\x1a\x07openvpn\x03net\x00\x07openvpn\x{03}com";
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test_dhcp.c:116:64: error: \x used with no following hex digits
  116 |     const char output_5[15] = "\x77\x0d\x03sub\x00\x{06}domain";
      |                                                                ^
test_dhcp.c:116:31: error: initializer-string for array of ‘char’ is too long [-Werror]
  116 |     const char output_5[15] = "\x77\x0d\x03sub\x00\x{06}domain";
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:3164: dhcp_testdriver-test_dhcp.o] Error 1
```

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 11 Oct 2025 09:06:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email

to look at the new patch set (#2).

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 154 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/2

CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +133 -0

133 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email

to look at the new patch set (#3).

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 154 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/3

CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +133 -0

133 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email

to look at the new patch set (#4).

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 155 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/4

CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +134 -0

134 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

Patch Set 4:

(1 comment)

Patchset:

PS1:

Quoted 1 line

``` […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 15:20:40 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

Patch Set 4: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 15:47:41 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#8 lore raw

PATCH v4 1/1 test_dhcp: Start a dhcp helper functions UT

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267
This mail reflects revision 4 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +134 -0

134 lines not on this page · raw message

#9 lore raw

[Openvpn-devel] [PATCH applied] Re: test_dhcp: Start a dhcp helper functions UT

UTs are welcome, it passes all the tests on all platforms now, so in it goes ;-) - the extra #ifdef is unavoidable, as we normally don't build the code tested here on non-WIN32 platforms...

Your patch has been applied to the master branch.

commit d78ebd4b8c11e3fb2ed8ceac56d955d7a9dffb13

Author: Frank Lichtenheld
Date:   Mon Oct 13 17:47:53 2025 +0200
     test_dhcp: Start a dhcp helper functions UT

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59246199/
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#10 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#5) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59246199/

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 155 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/1267/5

CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +134 -0

134 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#11 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email )

Change subject: test_dhcp: Start a dhcp helper functions UT
......................................................................

test_dhcp: Start a dhcp helper functions UT

Use extra define to allow testing code only
used on Windows but not actually dependent
on Windows.

Change-Id I08e50030b1b692d351509f541e5c0b03b5170615

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1267
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59246199/

---
M CMakeLists.txt
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
M src/openvpn/tun.h
M tests/unit_tests/openvpn/Makefile.am
M tests/unit_tests/openvpn/mock_msg.h
A tests/unit_tests/openvpn/test_dhcp.c

7 files changed, 155 insertions(+), 4 deletions(-)
CMakeLists.txt +6 -0
index 9e0b46e..b773dcb 100644
@@ -658,6 +658,7 @@
         "test_auth_token"
         "test_buffer"
         "test_crypto"
+        "test_dhcp"
         "test_misc"
         "test_ncp"
         "test_options_parse"
@@ -910,6 +911,11 @@
             )
     endif ()
 
+    target_compile_definitions(test_dhcp PRIVATE DHCP_UNIT_TEST)
+    target_sources(test_dhcp PRIVATE
+        tests/unit_tests/openvpn/mock_get_random.c
+        )
+
     if (TARGET test_networking)
         target_link_options(test_networking PRIVATE -Wl,--wrap=parse_line)
         target_compile_options(test_networking PRIVATE -UNDEBUG)
src/openvpn/dhcp.c +1 -1
index 56f03f2..0893ec7 100644
@@ -186,7 +186,7 @@
     return 0;
 }
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 
 #if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic push
src/openvpn/dhcp.h +1 -1
index 3fcd2b6..2ad31a6 100644
@@ -93,7 +93,7 @@
 
 in_addr_t dhcp_extract_router_msg(struct buffer *ipbuf);
 
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(DHCP_UNIT_TEST)
 #include "tun.h"
 
 bool build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o);
src/openvpn/tun.h +1 -1
index 6562c22..741798d 100644
@@ -59,7 +59,7 @@
 #define DCO_WIN_REFERENCE_STRING "ovpn-dco"
 #endif
 
-#if defined(_WIN32) || defined(TARGET_ANDROID)
+#if defined(_WIN32) || defined(TARGET_ANDROID) || defined(DHCP_UNIT_TEST)
 
 #define TUN_ADAPTER_INDEX_INVALID ((DWORD)-1)
 
tests/unit_tests/openvpn/Makefile.am +10 -1
index 50f4a11..17aa0ce 100644
@@ -6,7 +6,7 @@
 
 AM_TESTS_ENVIRONMENT = export LSAN_OPTIONS=suppressions=$(srcdir)/input/leak_suppr.txt;
 
-test_binaries = argv_testdriver buffer_testdriver crypto_testdriver packet_id_testdriver auth_token_testdriver \
+test_binaries = argv_testdriver buffer_testdriver crypto_testdriver dhcp_testdriver packet_id_testdriver auth_token_testdriver \
 	ncp_testdriver misc_testdriver options_parse_testdriver pkt_testdriver ssl_testdriver \
 	user_pass_testdriver push_update_msg_testdriver provider_testdriver socket_testdriver
 
@@ -72,6 +72,15 @@
 	$(top_srcdir)/src/openvpn/win32-util.c \
 	$(top_srcdir)/src/openvpn/mss.c
 
+dhcp_testdriver_CFLAGS  = -I$(top_srcdir)/src/openvpn -I$(top_srcdir)/src/compat @TEST_CFLAGS@ -DDHCP_UNIT_TEST
+dhcp_testdriver_LDFLAGS = @TEST_LDFLAGS@ -L$(top_srcdir)/src/openvpn
+dhcp_testdriver_SOURCES = test_dhcp.c \
+	mock_msg.c mock_msg.h test_common.h \
+	mock_get_random.c \
+	$(top_srcdir)/src/openvpn/platform.c \
+	$(top_srcdir)/src/openvpn/buffer.c \
+	$(top_srcdir)/src/openvpn/win32-util.c
+
 ssl_testdriver_CFLAGS  = \
 	-I$(top_srcdir)/include -I$(top_srcdir)/src/compat -I$(top_srcdir)/src/openvpn \
 	@TEST_CFLAGS@
tests/unit_tests/openvpn/mock_msg.h +2 -0
index c6321dc..62afde5 100644
@@ -23,6 +23,8 @@
 #ifndef MOCK_MSG_H
 #define MOCK_MSG_H
 
+#include "error.h"
+
 /**
  * Mock debug level defaults to 0, which gives clean(-ish) test reports.  Call
  * this function from your test driver to increase debug output when you
tests/unit_tests/openvpn/test_dhcp.c new file +134 -0

134 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1267?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I08e50030b1b692d351509f541e5c0b03b5170615
Gerrit-Change-Number: 1267
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>